<template>
    <div>
        <el-dialog :title="operationtype == 0 ? '设备操作' : '批量操作'" :visible.sync="dialogOperationVisible" width="45%"
            :show-close="false" :close-on-click-modal="false" style="height: 100%;" custom-class="customclassdialog">
            <el-form :model="formcs" style="max-height: 30%;overflow-y: auto;"
                :style="'max-height:' + windowHeight / 2 + 'px;'" v-if="multipleSelection.length == 0">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="所属企业:" :label-width="formLabelWidth" v-if="infoAlls.admin_name">
                            <div style="padding:0 20px;">
                                {{ infoAlls.admin_name }}
                            </div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="所属电站:" :label-width="formLabelWidth" v-if="infoAlls.base_station_name">
                            <div style="padding:0 20px;">
                                {{ infoAlls.base_station_name }}
                            </div>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="所属区域:" :label-width="formLabelWidth" v-if="infoAlls.region_name">
                            <div style="padding:0 20px;">
                                {{ infoAlls.region_name }}
                            </div>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>


            <div v-loading="loadings"
                :element-loading-text="'执行中，请等待' + (operationtype == 1 ? (sumProgress + '%') : '')"
                element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
                <el-form :model="formcs" style="max-height: 30%;overflow-y: auto;"
                    :style="'max-height:' + windowHeight / 2 + 'px;'">
                    <el-row v-if="operationtype == 0">
                        <el-col :span="12">
                            <el-form-item label="设备编码:" :label-width="formLabelWidth">
                                {{ formcs.equ_no }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="所属电站:" :label-width="formLabelWidth">
                                {{ formcs.base_station.name }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="所属区域:" :label-width="formLabelWidth">
                                {{ formcs.region.name }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12" v-if="formcs.status">
                            <el-form-item label="设备状态:" :label-width="formLabelWidth">
                                {{ equipmentstateoptions[formcs.status].label }}
                            </el-form-item>
                        </el-col>
                        <!-- <el-col :span="12">
                        <el-form-item label="使用时长:" :label-width="formLabelWidth">
                            {{ formcs.equipmentduration }}
                        </el-form-item>
                    </el-col> -->
                    </el-row>
                    <el-row v-else>
                        <el-col>
                            <el-form-item label="已选设备:" :label-width="formLabelWidth">
                                <div style="padding:0 20px;" v-if="multipleSelection.length > 0">
                                    <el-tag v-for="tag in multipleSelection" :key="tag.equ_no"
                                        style="margin-right: 10px;">
                                        {{ tag.equ_no }}
                                    </el-tag>
                                </div>
                                <div style="padding:0 20px;" v-else>
                                    全部设备
                                </div>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            <el-row class="mb15">
                                <el-col :span="12">
                                    <el-form-item label="运行模式:" :label-width="formLabelWidth">
                                        <el-radio-group v-model="formcs.run_mode" @input="runmodeHeld">
                                            <el-radio :label="0" border>自动</el-radio>
                                            <el-radio :label="1" border>手动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item label="清扫模式:" :label-width="formLabelWidth">
                                        <el-radio-group v-model="formcs.cleaning_mode" @input="cleaningmodeHeld">
                                            <el-radio :label="0" border>常规</el-radio>
                                            <el-radio :label="1" border>暴雪</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </el-col>
                        <el-col>
                            <el-row class="mb15" v-if="formcs.run_mode == 1">
                                <el-col :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;">
                                    <el-button v-repeatStop="{ func: advanceHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #02A8A6;border: #02A8A6;">前 进</el-button>
                                </el-col>
                                <el-col :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;">
                                    <el-button v-repeatStop="{ func: retreatHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;">后 退</el-button>
                                </el-col>
                                <el-col :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;">
                                    <el-button v-repeatStop="{ func: stopHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #C61E12;border: #C61E12;">停 止</el-button>
                                </el-col>
                                <el-col :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;">
                                    <el-button v-repeatStop="{ func: backHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #FFBF6B;border: #FFBF6B;">返 回</el-button>
                                </el-col>

                            </el-row>
                        </el-col>
                        <el-col>
                            <el-row>
                                <el-col :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;">
                                    <el-button v-repeatStop="{ func: parameterHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #0F40F5;border: #0F40F5;">参数设置</el-button>
                                </el-col>
                                <!-- <el-col v-if="operationtype == 0" :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;">
                                    <el-button v-repeatStop="{ func: videoHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #7728F5;border: #7728F5;">视频监控</el-button>
                                </el-col> -->
                                <!-- <el-col v-if="operationtype == 0" :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;">
                                    <el-button v-repeatStop="{ func: journalHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #81B337;border: #81B337;">日 志</el-button>
                                </el-col> -->
                                <el-col :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;">
                                    <el-button v-repeatStop="{ func: timingHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #48C1BF;border: #48C1BF;">定时任务</el-button>
                                </el-col>
                                <!-- <el-col :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;">
                                    <el-button v-repeatStop="{ func: setoldHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #C61E12;border: #C61E12;">执行历史</el-button>
                                </el-col> -->
                                <el-col :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;"
                                    v-if="operationtype == 1">
                                    <el-button v-repeatStop="{ func: openHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #67C23A;border: #67C23A;">启用</el-button>
                                </el-col>
                                <el-col :span="6"
                                    style="display: flex;align-items: center;justify-content: space-around;"
                                    v-if="operationtype == 1">
                                    <el-button v-repeatStop="{ func: bearHeld, delay: '2000' }" type="primary"
                                        style="min-width: 120px;background: #C61E12;border: #C61E12;">禁用</el-button>
                                </el-col>


                            </el-row>
                        </el-col>
                    </el-row>
                </el-form>
                <el-dialog width="60%" title="设置清扫日程" :visible.sync="timingVisible" append-to-body
                    style="height: 100%;margin-top: 6%;" custom-class="customclassdialog">
                    <el-form v-loading="loadingtr"
                        :element-loading-text="'执行中，请等待' + (operationtype == 1 ? (sumProgress + '%') : '')"
                        element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="天/星期:" :label-width="formLabelWidth">
                                    <screenSelect title="" type='select' v-model="formdw.name" :isValue='formdw.name'
                                        placeholder="请选择" @transfer="valueHeld($event, 'name')" :options="dwset"
                                        position="top" width='200px' />
                                </el-form-item>

                            </el-col>
                            <el-col :span="12" v-if="multipleSelection.length == 0 && idsall == ''">
                                <el-button v-repeatStop="{ func: historyHeld, delay: '2000' }" type="primary"
                                    style="min-width: 120px;background: #48C1BF;border: #48C1BF;">历史设置记录</el-button>
                            </el-col>
                            <el-col v-if="formdw.name == 'D'">
                                <el-form-item label="间隔:" :label-width="formLabelWidth">
                                    <screenSelect title="" type='input' v-model="formdw.value" :isValue='formdw.value'
                                        placeholder="请输入" @transfer="valueHeld($event, 'value')" width='200px'
                                        position="top" />
                                    <span>（1为每天、2为间隔一天以此类推）</span>
                                </el-form-item>
                            </el-col>
                            <el-col v-if="formdw.name == 'W'">
                                <el-form-item label="星期:" :label-width="formLabelWidth">
                                    <el-checkbox-group v-model="checkboxGroup1" size="small">
                                        <el-checkbox style="width: 80px;margin: 0 10px;" label="W1"
                                            border>星期一</el-checkbox>
                                        <el-checkbox style="width: 80px;margin: 0 10px" label="W2"
                                            border>星期二</el-checkbox>
                                        <el-checkbox style="width: 80px;margin: 0 10px" label="W3"
                                            border>星期三</el-checkbox>
                                        <el-checkbox style="width: 80px;margin: 0 10px" label="W4"
                                            border>星期四</el-checkbox>
                                        <el-checkbox style="width: 80px;margin: 0 10px" label="W5"
                                            border>星期五</el-checkbox>
                                        <el-checkbox style="width: 80px;margin: 0 10px" label="W6"
                                            border>星期六</el-checkbox>
                                        <el-checkbox style="width: 80px;margin: 0 10px" label="W7"
                                            border>星期日</el-checkbox>
                                    </el-checkbox-group>
                                </el-form-item>
                            </el-col>
                            <el-col>
                                <el-form-item label="时间点:" :label-width="formLabelWidth">
                                    <el-row>
                                        <el-col style="margin-bottom: 10px;width: 240px;"
                                            v-for="(item, index) in timepickerlist" :key="index">
                                            <el-time-picker v-model="item.value" placeholder="时间点"
                                                style="width: 140px;">
                                            </el-time-picker>
                                            <el-button size="mini" :type="item.state == 'E' ? 'danger' : 'success'"
                                                style="margin-left: 10px;" @click="statusTab(index)">{{
                                                    item.state == 'E' ? '禁' : '启' }}</el-button>
                                            <el-button style="margin-left: 10px;" type="danger" icon="el-icon-delete"
                                                size="mini" circle @click="deletetime(index)"
                                                v-if="timepickerlist.length > 1"></el-button>
                                        </el-col>
                                        <el-col :span="5">
                                            <el-button type="primary" size="mini" plain @click="addtime"
                                                v-if="timepickerlist.length < 10">新增节点</el-button>
                                        </el-col>
                                    </el-row>

                                </el-form-item>
                            </el-col>
                            <el-col>
                                <el-form-item label="生效时间:" :label-width="formLabelWidth">
                                    <el-date-picker v-model="formdw.T003" type="datetime" placeholder="请选择"
                                        style="width: 200px;">
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="canceltr" :disabled="loadingtr">关 闭</el-button>
                        <el-button type="primary" :disabled="loadingtr" @click="timingVisibleHeld">保 存</el-button>
                    </div>
                </el-dialog>

                <el-dialog title="历史记录" width="60%" :visible.sync="timingVisiblerz" append-to-body>
                    <el-table :data="timinglist">
                        <el-table-column label="设备编码" min-width="140" align="center">
                            <template slot-scope="scope">
                                {{ scope.row.equ_no }}
                            </template>
                        </el-table-column>
                        <el-table-column label="天/星期" min-width="140" align="center">
                            <template slot-scope="scope">
                                {{ scope.row.T001 }}
                            </template>
                        </el-table-column>
                        <el-table-column label="时间点" min-width="140" align="center">
                            <template slot-scope="scope">
                                {{ scope.row.T002_arr.join(',') }}
                            </template>
                        </el-table-column>
                        <el-table-column label="生效时间" min-width="140" align="center">
                            <template slot-scope="scope">
                                {{ scope.row.daytime.toString().substring(0, 4) + '-' +
                                    scope.row.daytime.toString().substring(4, 6) + '-' +
                                    scope.row.daytime.toString().substring(6) }}
                            </template>
                        </el-table-column>

                    </el-table>
                    <div class="" v-if="total > 0" style="display: flex;justify-content: end;margin-top: 10px;">
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                            :current-page="pageData.page" :page-sizes="[10, 20, 30, 40]" :page-size="pageData.limit"
                            :background="true" layout="total, sizes, prev, pager, next, jumper" :total="total">
                        </el-pagination>
                    </div>
                </el-dialog>

                <el-dialog title="执行详情" width="40%" :visible.sync="isEndDataNext" append-to-body>
                    <el-table :data="endDataNext" max-height="400">
                        <el-table-column label="设备编码" min-width="200" align="center">
                            <template slot-scope="scope">
                                {{ scope.row.equ_no }}
                            </template>
                        </el-table-column>
                        <el-table-column label="执行结果" min-width="80" align="center">
                            <template slot-scope="scope">
                                {{ scope.row.status == 1 ? '执行成功' : '执行失败' }}
                            </template>
                        </el-table-column>
                    </el-table>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="EndDataNextHeld">关 闭</el-button>
                    </div>
                </el-dialog>

                <el-dialog :width="role == 0 ? '45%' : '60%'" title="参数设置" :visible.sync="innerVisible" append-to-body
                    style="height: 100%;margin-top: 6%;" custom-class="customclassdialog">
                    <el-form v-loading="loadingsd" :model="formgly"
                        :element-loading-text="'执行中，请等待' + (operationtype == 1 ? (sumProgress + '%') : '')"
                        element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
                        <el-row>
                            <el-col :span="role == 0 ? 24 : 12">
                                <div class="seilddiys">
                                    <div class="seilddiys_title">PVC正常移动速度（mm/s）：
                                    </div>
                                    <slisd :min="0" :max="300" :value="S001" :isDrag="true" bgColor="#0081ff"
                                        @input="S001Held"></slisd>
                                </div>
                                <div class="seilddiys">
                                    <div class="seilddiys_title">PVC暴雪模式下移动速度（mm/s）：
                                    </div>
                                    <slisd :min="0" :max="300" :value="S002" :isDrag="true" bgColor="#f37b1d"
                                        @input="S002Held"></slisd>
                                </div>
                                <div class="seilddiys">
                                    <div class="seilddiys_title">清扫电机正常模式下功率（%）：
                                    </div>
                                    <slisd :min="0" :max="100" :value="S003" :isDrag="true" bgColor="#8dc63f"
                                        @input="S003Held"></slisd>
                                </div>
                                <div class="seilddiys">
                                    <div class="seilddiys_title">清扫电机暴雪模式下功率（%）：
                                    </div>
                                    <slisd :min="0" :max="100" :value="S004" :isDrag="true" bgColor="#e54d42"
                                        @input="S004Held"></slisd>
                                </div>
                                <div class="seilddiys">
                                    <div class="seilddiys_title">清扫电机自清洗功率（%）：
                                    </div>
                                    <slisd :min="0" :max="100" :value="S005" :isDrag="true" bgColor="#fbbd08"
                                        @input="S005Held"></slisd>
                                </div>
                            </el-col>
                            <el-col v-if="role == 1" :span="12">
                                <el-row :gutter="20">
                                    <el-col :span="12">
                                        <screenSelect title="系统保护电流(mA):" type='inputnumber' v-model="S007"
                                            :isValue='S007' placeholder="默认值：待定" @transfer="valueHelds($event, 'S007')"
                                            width='100%' position="top" />
                                    </el-col>
                                    <el-col :span="12">
                                        <screenSelect title="主驱动电机保护电流(mA):" type='inputnumber' v-model="S008"
                                            :isValue='S008' placeholder="默认值：待定" @transfer="valueHelds($event, 'S008')"
                                            width='100%' position="top" />
                                    </el-col>
                                    <el-col :span="12">
                                        <screenSelect title="辅助驱动电机保护电流(mA):" type='inputnumber' v-model="S009"
                                            :isValue='S009' placeholder="默认值：待定" @transfer="valueHelds($event, 'S009')"
                                            width='100%' position="top" />
                                    </el-col>
                                    <el-col :span="12">
                                        <screenSelect title="清扫电机保护电流(mA):" type='inputnumber' v-model="S010"
                                            :isValue='S010' placeholder="默认值：待定" @transfer="valueHelds($event, 'S010')"
                                            width='100%' position="top" />
                                    </el-col>
                                    <el-col :span="12">
                                        <screenSelect title="电池低压保护电压(mV):" type='inputnumber' v-model="S011"
                                            :isValue='S011' placeholder="默认值：待定" @transfer="valueHelds($event, 'S011')"
                                            width='100%' position="top" />
                                    </el-col>
                                    <el-col :span="12">
                                        <screenSelect title="电池恢复工作电压(mV):" type='inputnumber' v-model="S012"
                                            :isValue='S012' placeholder="默认值：待定" @transfer="valueHelds($event, 'S012')"
                                            width='100%' position="top" />
                                    </el-col>
                                    <el-col :span="12">
                                        <screenSelect title="反向等待时间(秒):" type='inputnumber' v-model="S013"
                                            :isValue='S013' placeholder="默认值：5" @transfer="valueHelds($event, 'S013')"
                                            width='100%' position="top" />
                                    </el-col>
                                    <el-col :span="12">
                                        <screenSelect title="清扫刷自清洗时间(秒):" type='inputnumber' v-model="S014"
                                            :isValue='S014' placeholder="默认值：15" @transfer="valueHelds($event, 'S014')"
                                            width='100%' position="top" />
                                    </el-col>
                                    <el-col :span="12">
                                        <screenSelect title="清扫数据上传时间间隔(秒):" type='inputnumber' v-model="S015"
                                            :isValue='S015' placeholder="默认值：120" @transfer="valueHelds($event, 'S015')"
                                            width='100%' position="top" />
                                    </el-col>
                                    <el-col :span="12">
                                        <screenSelect title="非工作数据上传时间间隔(秒):" type='inputnumber' v-model="S016"
                                            :isValue='S016' placeholder="默认值：1800"
                                            @transfer="valueHelds($event, 'S016')" width='100%' position="top" />
                                    </el-col>
                                </el-row>
                            </el-col>
                        </el-row>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button type="primary" :disabled="loadingsd" @click="innerVisibleHeld">保 存</el-button>
                    </div>
                </el-dialog>
                <el-dialog width="80%" title="视频监控" :visible.sync="videoInnerVisible" append-to-body
                    style="height: 100%;margin-top: 6%;" custom-class="customclassdialog">
                    <el-form>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="设备编码:" :label-width="formLabelWidth">
                                    {{ formcs.equipmentname }}
                                </el-form-item>
                            </el-col>
                            <el-col>
                                <video v-if="videoInnerVisible" disablepictureinpicture
                                    controlsList="nodownload noplaybackrate" width="100%" controls autoplay
                                    style="width: 100%;height: 500px;"
                                    src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"></video>
                            </el-col>
                        </el-row>
                    </el-form>

                </el-dialog>

            </div>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancel(false)" :disabled="loadings">关 闭</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { getequsetList, equtimershow, getequtimerList, equsettimer, equsettimerresult, equbatchtimerresult, equmovecommand, equresult, equsetresult, equswitchcontrol, equsetcleaningmode, equsetconfig, equsetshow, equbatchswitchcontrol, equbatchsetcleaningmode, equbatchmovecommand, equbatchsetconfig, equstopstart } from '@/api/equipment'
import slisd from '@/components/progressdiy/index.vue';
import screenSelect from '@/components/screenSelect/index.vue';
import { parseTime, parseTimehis } from '@/utils/ruoyi.js'
export default {
    name: 'WorkspaceJsonOperation',
    components: {
        slisd, screenSelect
    },
    props: {
        operationtype: {
            type: String
        },
        optionVal: {
            type: Object
        },
        dialogOperationVisible: {
            type: Boolean
        },
        multipleSelection: {
            type: Array
        },
        idsall: {
            type: String
        },
        infoAll: {
            type: Object,
            default: {}
        },
    },
    watch: {
        optionVal: {
            handler(ne, ol) {
                this.formcs = ne
            },
            deep: true,
            immediate: true
        },
        infoAll: {
            handler(ne, ol) {
                this.infoAlls = ne
            },
            deep: true,
            immediate: true
        }
    },
    data() {
        return {
            infoAlls: {},
            value2: new Date(2016, 9, 10, 18, 40),
            ids: '',
            sumProgress: 0,
            S001: 50,
            S002: 50,
            S003: 70,
            S004: 70,
            S005: 70,
            S007: '',
            S008: '',
            S009: '',
            S010: '',
            S011: '',
            S012: '',
            S013: '',
            S014: '',
            S015: '',
            S016: '',
            loadings: false,
            loadingsd: false,
            loadingsdt: false,
            loadingtr: false,
            formLabelWidth: '100px',
            formLabelWidths: '200px',
            role: 0,
            formcs: {},
            formgly: {},
            srcList: [],
            equipmentstateoptions: [
                {
                    label: '停止',
                    value: 0
                },
                {
                    label: '正常',
                    value: 1
                },
                {
                    label: '报警',
                    value: 2
                },
                {
                    label: '离线',
                    value: 3
                },
                {
                    label: '检修',
                    value: 4
                },
            ],
            dwset: [
                {
                    label: '天',
                    value: 'D'
                },
                {
                    label: '星期',
                    value: 'W'
                },
            ],
            formdw: { name: 'D', value: '', T003: '' },
            checkboxGroup1: [],
            timepickerlist: [{ value: '', state: 'E' }],
            tags: [
                { name: 'CN001', type: '' },
                { name: 'CN002', type: '' },
                { name: 'CN003', type: '' },
                { name: 'CN004', type: '' },
                { name: 'CN005', type: '' },
                { name: 'CN006', type: '' },
            ],
            windowHeight: 0,
            innerVisible: false,
            videoInnerVisible: false,
            timingVisible: false,
            timingVisiblerz: false,
            timinglist: [],
            pageData: {
                page: 1,
                limit: 10
            },
            total: 0,
            pageDatas: {
                page: 1,
                limit: 10
            },
            totals: 0,
            // 执行结果
            endDataNext: [{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            },{
                equ_no: 'qw',
                status: 0
            }],
            isEndDataNext: false

        };
    },
    mounted() {
        this.windowHeight = document.body.clientHeight;
        if (this.idsall == '') {
            let str_id = ''
            this.multipleSelection.map(item => {
                str_id += item.id + ','
            })
            this.ids = str_id.slice(0, -1)
        }
        if (JSON.parse(localStorage.getItem('name')).role) {
            this.role = JSON.parse(localStorage.getItem('name')).role
        } else {
            this.role = 0
        }
    },

    methods: {
        EndDataNextHeld(){
            let that = this
            that.isEndDataNext = false
            that.endDataNext = []
        },
        //启用
        openHeld() {
            let that = this
            let data = {}
            data.type = 1
            data.equ_id = that.idsall == '' ? that.ids : that.idsall
            that.loadings = true
            equstopstart(data).then(res => {
                console.log(res);
                if (res.code == 200) {
                    if (res.data.length == 0) {
                        that.loadings = false
                        that.$modal.msgError('请核实设备')
                        return
                    }
                    let arr = []
                    that.executeSequentialRequests(res.data, 0, (respons) => {
                        if (respons != 'ok') {
                            arr.push(respons)

                        } else {
                            //待测
                            that.endDataNext = arr

                            let errorData = []
                            let errorStr = ''
                            arr.map(item => {
                                if (item.status == 0) {
                                    errorData.push(item)
                                    errorStr += item.equ_no + ','
                                }
                            })
                            that.loadings = false
                            if (errorData.length > 0) {
                                that.isEndDataNext = true

                                // errorStr = errorStr + '处理超时,请查看执行日志!'
                                // that.$alert('设备' + errorStr, '执行结果', {
                                //     confirmButtonText: '确定',
                                // });
                            } else {
                                that.$modal.msgSuccess('执行成功')
                                that.cancel('a')
                            }

                            console.log(respons, '12311313', errorData);
                        }
                    })
                } else {
                    that.loadings = false
                    that.$modal.msgError(res.message)
                }
            })
        },
        //禁用
        bearHeld() {

            let that = this
            let data = {}
            data.type = 0
            data.equ_id = that.idsall == '' ? that.ids : that.idsall
            that.loadings = true
            equstopstart(data).then(res => {
                console.log(res);
                if (res.code == 200) {
                    if (res.data.length == 0) {
                        that.loadings = false
                        that.$modal.msgError('请核实设备')
                        return
                    }
                    let arr = []
                    that.executeSequentialRequests(res.data, 0, (respons) => {
                        if (respons != 'ok') {
                            arr.push(respons)

                        } else {
                            //待测
                            that.endDataNext = arr
                            let errorData = []
                            let errorStr = ''
                            arr.map(item => {
                                if (item.status == 0) {
                                    errorData.push(item)
                                    errorStr += item.equ_no + ','
                                }
                            })
                            that.loadings = false
                            if (errorData.length > 0) {
                                that.isEndDataNext = true

                                // errorStr = errorStr + '处理超时,请查看执行日志!'
                                // that.$alert('设备' + errorStr, '执行结果', {
                                //     confirmButtonText: '确定',
                                // });
                            } else {
                                that.$modal.msgSuccess('执行成功')
                                that.cancel('a')

                            }

                            console.log(respons, '12311313', errorData);
                        }
                    })
                } else {
                    that.loadings = false
                    that.$modal.msgError(res.message)
                }
            })
        },
        addtime() {
            console.log('添加');
            this.timepickerlist.push({ value: '', state: 'E' })
        },
        deletetime(index) {
            this.timepickerlist.splice(index, 1)
        },
        statusTab(index) {
            if (this.timepickerlist[index].state == 'E') {
                this.timepickerlist[index].state = 'D'
            } else {
                this.timepickerlist[index].state = 'E'
            }
        },
        valueHeld(childParam, fatherparam) {
            this.formdw[fatherparam] = childParam
        },
        valueHelds(childParam, fatherparam) {
            this[fatherparam] = childParam


        },
        getList() {
            let that = this
            let data = {}
            data.equ_id = that.formcs.id
            equsetshow(data).then(res => {
                if (res.code == 200) {
                    that.S001 = Number(res.data.S001)
                    that.S002 = Number(res.data.S002)
                    that.S003 = Number(res.data.S003)
                    that.S004 = Number(res.data.S004)
                    that.S005 = Number(res.data.S005)
                    if (that.role == 1) {
                        that.S007 = Number(res.data.S007)
                        that.S008 = Number(res.data.S008)
                        that.S009 = Number(res.data.S009)
                        that.S010 = Number(res.data.S010)
                        that.S011 = Number(res.data.S011)
                        that.S012 = Number(res.data.S012)
                        that.S013 = Number(res.data.S013)
                        that.S014 = Number(res.data.S014)
                        that.S015 = Number(res.data.S015)
                        that.S016 = Number(res.data.S016)
                    }
                    that.innerVisible = true
                    console.log(res.data);
                }
            })
        },
        gettrList() {
            let that = this
            let data = {}
            data.equ_no = that.formcs.equ_no
            data.page = that.pageData.page
            data.limit = that.pageData.limit
            getequtimerList(data).then(res => {
                if (res.code == 200) {
                    res.data.rows.map(item => {
                        if (item.T001.indexOf('D') != -1) {
                            if (item.T001.substring(1) == 1) {
                                item.T001 = '每天'
                            } else {
                                item.T001 = item.T001.substring(1) + '天'
                            }

                        } else {
                            let str = item.T001.split('W')
                            let arr = []
                            str.map(v => {
                                if (v == 1) {
                                    arr.push('星期一')
                                } else if (v == 2) {
                                    arr.push('星期二')
                                } else if (v == 3) {
                                    arr.push('星期三')
                                } else if (v == 4) {
                                    arr.push('星期四')
                                } else if (v == 5) {
                                    arr.push('星期五')
                                } else if (v == 6) {
                                    arr.push('星期六')
                                } else if (v == 7) {
                                    arr.push('星期日')
                                }
                            })
                            item.T001 = arr.join(',')

                        }
                    })
                    that.timinglist = res.data.rows
                    that.total = res.data.count
                    that.timingVisiblerz = true
                } else {
                    that.$modal.msgError(res.message)
                }
            })
        },
        getFxList() {
            let data = {}
            data.equ_no = this.formcs.equ_no
            equtimershow(data).then(res => {
                if (res.code == 200) {
                    console.log(res.data);
                    if (res.data) {
                        if (res.data.T001 != '') {
                            if (res.data.T001.substring(0, 1) == 'D') {
                                this.formdw.name = 'D'
                                this.formdw.value = res.data.T001.substring(1)
                            } else {
                                this.formdw.name = 'W'
                                this.checkboxGroup1 = res.data.T001.match(/.{1,2}/g)
                            }
                        } else {
                            this.formdw.name = 'D'
                            this.formdw.value = res.data.T001
                        }

                        let strdiy = res.data.T003.toString().substring(0, 4) + '-' +
                            res.data.T003.toString().substring(4, 6) + '- ' +
                            res.data.T003.toString().substring(6, 8) + ' ' + res.data.T003.toString().substring(8, 10) + ':' + res.data.T003.toString().substring(10, 12) + ':' + res.data.T003.toString().substring(12, 14)
                        this.formdw.T003 = new Date(strdiy)
                        let sjdarr = res.data.T002.split(',')
                        this.timepickerlist = []
                        sjdarr.map(item => {
                            let obj = {}
                            obj.state = item.substring(4)

                            obj.value = this.convertToTimeFormat(item.substring(0, 2) + ':' + item.substring(2, 4))
                            console.log(obj);

                            this.timepickerlist.push(obj)
                        })


                    } else {
                        this.formdw = { name: 'D', value: '', T003: '' }
                        this.checkboxGroup1 = []
                        this.timepickerlist = [{ value: '', state: 'E' }]
                    }


                    this.timingVisible = true
                }

            })
        },
        getoldList() {
            let data = {}
            data.equ_id = this.formcs.id
            data.page = this.pageDatas.page
            getequsetList(data).then(res => {
                console.log(res);

            })
        },
        convertToTimeFormat(timeString) {
            const parts = timeString.split(':');
            const hours = parseInt(parts[0], 10);
            const minutes = parseInt(parts[1], 10);
            const seconds = 0; // 如果你想要秒，可以设置为0
            return new Date(1970, 0, 1, hours, minutes, seconds);
        },
        handleSizeChange(val) {
            this.pageData.limit = val
            this.gettrList()
        },
        handleCurrentChange(val) {
            this.pageData.page = val
            this.gettrList()

        },
        handleSizeChanges(val) {
            this.pageData.limit = val
            this.getoldList()
        },
        handleCurrentChanges(val) {
            this.pageDatas.page = val
            this.getoldList()

        },
        S001Held(e) {
            this.S001 = e
        },
        S002Held(e) {
            this.S002 = e
        },
        S003Held(e) {
            this.S003 = e
        },
        S004Held(e) {
            this.S004 = e
        },
        S005Held(e) {
            this.S005 = e
        },
        equResult(equno, MessageId) {
            let defaultConfig = {
                time: 1000, // 轮询间隔
                times: localStorage.getItem('overtime') ? localStorage.getItem('overtime') : 5, // 轮询次数
            }
            let t = 0;
            return new Promise((resolve, reject) => {
                let data = {}
                data.equ_no = equno
                data.message_id = MessageId
                const f = () => {
                    equresult(data).then(res => {
                        if (res.code == 200) {
                            resolve(res)
                            return
                        }
                        t++;
                        if (t >= defaultConfig.times) {
                            resolve(res)
                            return;
                        } else {
                            setTimeout(f, defaultConfig.time)
                        }
                    })
                }
                f()
            })

        },
        //参数轮询
        equSetResult(equno, MessageId) {
            let defaultConfig = {
                time: 1000, // 轮询间隔
                times: localStorage.getItem('overtime') ? localStorage.getItem('overtime') : 5, // 轮询次数
            }
            let t = 0;
            return new Promise((resolve, reject) => {
                let data = {}
                data.equ_no = equno
                data.message_id = MessageId
                const f = () => {
                    equsetresult(data).then(res => {
                        if (res.code == 200) {
                            resolve(res)
                            return
                        }
                        t++;
                        if (t >= defaultConfig.times) {
                            resolve(res)
                            return;
                        } else {
                            setTimeout(f, defaultConfig.time)
                        }
                    })
                }
                f()
            })

        },
        equSetTimerResult(equno, MessageId) {
            let defaultConfig = {
                time: 1000, // 轮询间隔
                times: localStorage.getItem('overtime') ? localStorage.getItem('overtime') : 5, // 轮询次数
            }
            let t = 0;
            return new Promise((resolve, reject) => {
                let data = {}
                data.equ_no = equno
                data.message_id = MessageId
                const f = () => {
                    equsettimerresult(data).then(res => {
                        if (res.code == 200) {
                            resolve(res)
                            return
                        }
                        t++;
                        if (t >= defaultConfig.times) {
                            resolve(res)
                            return;
                        } else {
                            setTimeout(f, defaultConfig.time)
                        }
                    })
                }
                f()
            })

        },

        sumProgressfun(data, index) {
            let that = this
            let intervalId = null
            console.log(index, '第几次');
            let count = 0;
            if (index == 0) {
                count = 0;
            } else {
                count = parseInt(100 / data) * index
            }
            console.log(count, '测试');
            let max = 100;
            if (index == 0) {
                max = parseInt(100 / data);
            } else {
                max = parseInt(100 / data) * (index + 1)
            }
            if (max == 100) {
                max = 99
            }
            let interval = 5000;
            intervalId = setInterval(() => {
                if (count < max) {
                    count++;
                    that.sumProgress = count
                } else {
                    clearInterval(intervalId); // 停止计时器
                }
            }, parseInt(interval / parseInt(100 / data)));
        },
        executeSequentialRequests(array, index, callback) {
            let that = this
            if (array.length >= index + 1) {
                that.sumProgressfun(array.length, index)
            }
            if (index >= array.length) {
                // 所有请求都执行完毕
                callback('ok');
                return;
            }
            that.equResult(array[index].equ_no, array[index].message_id).then(res => {
                let obj = {}
                obj.equ_no = array[index].equ_no
                obj.message = res.message
                if (res.code == 200) {
                    obj.status = 1
                } else {
                    obj.status = 0
                }
                callback(obj)
                that.executeSequentialRequests(array, index + 1, callback);
            })
        },
        //参数设置
        executeSequentialRequestst(array, index, callback) {
            let that = this
            if (array.length >= index + 1) {
                that.sumProgressfun(array.length, index)
            }
            if (index >= array.length) {
                // 所有请求都执行完毕
                callback('ok');
                return;
            }
            that.equSetResult(array[index].equ_no, array[index].message_id).then(res => {
                let obj = {}
                obj.equ_no = array[index].equ_no
                obj.message = res.message
                if (res.code == 200) {
                    obj.status = 1
                } else {
                    obj.status = 0
                }
                callback(obj)
                that.executeSequentialRequestst(array, index + 1, callback);
            })
        },
        //定时任务
        executeSequentialRequeststr(array, index, callback) {
            let that = this
            if (array.length >= index + 1) {
                that.sumProgressfun(array.length, index)
            }
            if (index >= array.length) {
                // 所有请求都执行完毕
                callback('ok');
                return;
            }
            that.equSetTimerResult(array[index].equ_no, array[index].message_id).then(res => {
                let obj = {}
                obj.equ_no = array[index].equ_no
                obj.message = res.message
                if (res.code == 200) {
                    obj.status = 1
                } else {
                    obj.status = 0
                }
                callback(obj)
                that.executeSequentialRequestst(array, index + 1, callback);
            })
        },
        runmodeHeld(e) {
            let that = this
            that.sumProgress = 0
            if (this.operationtype == 0) {
                let data = {}
                data.equ_id = this.formcs.id
                data.type = e
                that.loadings = true
                equswitchcontrol(data).then(res => {
                    if (res.code == 200) {
                        that.equResult(that.formcs.equ_no, res.data.message_id).then(resd => {
                            if (resd.code == 200) {
                                that.loadings = false
                                that.$modal.msgSuccess(resd.message)
                            } else {
                                that.loadings = false
                                that.$modal.msgError('设置超时，执行结果请查看执行记录!')
                            }
                        })
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })
            } else {
                let data = {}
                data.type = e
                data.equ_id = that.idsall == '' ? that.ids : that.idsall
                that.loadings = true
                equbatchswitchcontrol(data).then(res => {
                    console.log(res);
                    if (res.code == 200) {
                        if (res.data.length == 0) {
                            that.loadings = false
                            that.$modal.msgError('请核实设备')
                            return
                        }
                        let arr = []
                        that.executeSequentialRequests(res.data, 0, (respons) => {
                            if (respons != 'ok') {
                                arr.push(respons)

                            } else {
                                //待测
                                that.endDataNext = arr
                                let errorData = []
                                let errorStr = ''
                                arr.map(item => {
                                    if (item.status == 0) {
                                        errorData.push(item)
                                        errorStr += item.equ_no + ','
                                    }
                                })
                                that.loadings = false
                                if (errorData.length > 0) {
                                    that.isEndDataNext = true

                                    // errorStr = errorStr + '处理超时,请查看执行日志!'
                                    // that.$alert('设备' + errorStr, '执行结果', {
                                    //     confirmButtonText: '确定',
                                    // });
                                } else {
                                    that.$modal.msgSuccess('执行成功')

                                }

                                console.log(respons, '12311313', errorData);
                            }
                        })


                        // that.$modal.msgSuccess(res.message)
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })
                console.log(that.multipleSelection, '批量', data);
            }

        },
        cleaningmodeHeld(e) {
            let that = this
            that.sumProgress = 0
            if (that.operationtype == 0) {
                let data = {}
                data.equ_id = this.formcs.id
                data.type = e
                that.loadings = true
                equsetcleaningmode(data).then(res => {
                    if (res.code == 200) {
                        that.equResult(that.formcs.equ_no, res.data.message_id).then(resd => {
                            if (resd.code == 200) {
                                that.loadings = false
                                that.$modal.msgSuccess(resd.message)
                            } else {
                                that.loadings = false
                                that.$modal.msgError('设置超时，执行结果请查看执行记录!')
                            }
                        })
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })
            } else {
                let data = {}
                data.type = e
                data.equ_id = that.idsall == '' ? that.ids : that.idsall
                that.loadings = true
                equbatchsetcleaningmode(data).then(res => {
                    console.log(res);
                    if (res.code == 200) {
                        if (res.data.length == 0) {
                            that.loadings = false
                            that.$modal.msgError('请核实设备')
                            return
                        }
                        let arr = []
                        that.executeSequentialRequests(res.data, 0, (respons) => {
                            if (respons != 'ok') {
                                arr.push(respons)

                            } else {
                                //待测
                                that.endDataNext = arr
                                let errorData = []
                                let errorStr = ''
                                arr.map(item => {
                                    if (item.status == 0) {
                                        errorData.push(item)
                                        errorStr += item.equ_no + ','
                                    }
                                })
                                that.loadings = false
                                if (errorData.length > 0) {
                                    that.isEndDataNext = true

                                    // errorStr = errorStr + '处理超时,请查看执行日志!'
                                    // that.$alert('设备' + errorStr, '执行结果', {
                                    //     confirmButtonText: '确定',
                                    // });
                                } else {
                                    that.$modal.msgSuccess('执行成功')

                                }

                                console.log(respons, '12311313', errorData);
                            }
                        })
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })
                console.log(that.multipleSelection, '批量', data);
            }

        },
        advanceHeld() {
            let that = this
            that.sumProgress = 0
            if (this.operationtype == 0) {
                let data = {}
                data.type = 1
                data.equ_id = this.formcs.id
                that.loadings = true
                equmovecommand(data).then(res => {
                    if (res.code == 200) {
                        that.equResult(that.formcs.equ_no, res.data.message_id).then(resd => {
                            if (resd.code == 200) {
                                that.loadings = false
                                that.$modal.msgSuccess(resd.message)
                            } else {
                                that.loadings = false
                                that.$modal.msgError('设置超时，执行结果请查看执行记录!')
                            }
                        })
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })
            } else {
                let data = {}
                data.type = 1
                data.equ_id = that.idsall == '' ? that.ids : that.idsall
                that.loadings = true
                equbatchmovecommand(data).then(res => {

                    console.log(res);
                    if (res.code == 200) {
                        if (res.data.length == 0) {
                            that.loadings = false
                            that.$modal.msgError('请核实设备')
                            return
                        }
                        let arr = []
                        that.executeSequentialRequests(res.data, 0, (respons) => {
                            if (respons != 'ok') {
                                arr.push(respons)

                            } else {
                                //待测
                                that.endDataNext = arr
                                let errorData = []
                                let errorStr = ''
                                arr.map(item => {
                                    if (item.status == 0) {
                                        errorData.push(item)
                                        errorStr += item.equ_no + ','
                                    }
                                })
                                that.loadings = false
                                if (errorData.length > 0) {
                                    that.isEndDataNext = true

                                    // errorStr = errorStr + '处理超时,请查看执行日志!'
                                    // that.$alert('设备' + errorStr, '执行结果', {
                                    //     confirmButtonText: '确定',
                                    // });
                                } else {
                                    that.$modal.msgSuccess('执行成功')

                                }

                                console.log(respons, '12311313', errorData);
                            }
                        })


                        // that.$modal.msgSuccess(res.message)
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })

            }

            console.log('前进', this.form);
        },
        retreatHeld() {
            let that = this
            that.sumProgress = 0
            if (this.operationtype == 0) {
                let data = {}
                data.type = 2
                data.equ_id = this.formcs.id
                that.loadings = true
                equmovecommand(data).then(res => {
                    if (res.code == 200) {
                        that.equResult(that.formcs.equ_no, res.data.message_id).then(resd => {
                            if (resd.code == 200) {
                                that.loadings = false
                                that.$modal.msgSuccess(resd.message)
                            } else {
                                that.loadings = false
                                that.$modal.msgError('设置超时，执行结果请查看执行记录!')
                            }
                        })
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })
            } else {
                let data = {}
                data.type = 2
                data.equ_id = that.idsall == '' ? that.ids : that.idsall
                that.loadings = true
                equbatchmovecommand(data).then(res => {

                    console.log(res);
                    if (res.code == 200) {
                        if (res.data.length == 0) {
                            that.loadings = false
                            that.$modal.msgError('请核实设备')
                            return
                        }
                        let arr = []
                        that.executeSequentialRequests(res.data, 0, (respons) => {
                            if (respons != 'ok') {
                                arr.push(respons)

                            } else {
                                //待测
                                that.endDataNext = arr
                                let errorData = []
                                let errorStr = ''
                                arr.map(item => {
                                    if (item.status == 0) {
                                        errorData.push(item)
                                        errorStr += item.equ_no + ','
                                    }
                                })
                                that.loadings = false
                                if (errorData.length > 0) {
                                    that.isEndDataNext = true

                                    // errorStr = errorStr + '处理超时,请查看执行日志!'
                                    // that.$alert('设备' + errorStr, '执行结果', {
                                    //     confirmButtonText: '确定',
                                    // });
                                } else {
                                    that.$modal.msgSuccess('执行成功')

                                }

                                console.log(respons, '12311313', errorData);
                            }
                        })


                        // that.$modal.msgSuccess(res.message)
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })

            }
            console.log('后退', this.form);
        },
        stopHeld() {
            let that = this
            that.sumProgress = 0
            if (this.operationtype == 0) {
                let data = {}
                data.type = 3
                data.equ_id = this.formcs.id
                that.loadings = true
                equmovecommand(data).then(res => {
                    if (res.code == 200) {
                        that.equResult(that.formcs.equ_no, res.data.message_id).then(resd => {
                            if (resd.code == 200) {
                                that.loadings = false
                                that.$modal.msgSuccess(resd.message)
                            } else {
                                that.loadings = false
                                that.$modal.msgError('设置超时，执行结果请查看执行记录!')
                            }
                        })
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })
            } else {
                let data = {}
                data.type = 3
                data.equ_id = that.idsall == '' ? that.ids : that.idsall
                that.loadings = true
                equbatchmovecommand(data).then(res => {

                    console.log(res);
                    if (res.code == 200) {
                        if (res.data.length == 0) {
                            that.loadings = false
                            that.$modal.msgError('请核实设备')
                            return
                        }
                        let arr = []
                        that.executeSequentialRequests(res.data, 0, (respons) => {
                            if (respons != 'ok') {
                                arr.push(respons)

                            } else {
                                //待测
                                that.endDataNext = arr
                                let errorData = []
                                let errorStr = ''
                                arr.map(item => {
                                    if (item.status == 0) {
                                        errorData.push(item)
                                        errorStr += item.equ_no + ','
                                    }
                                })
                                that.loadings = false
                                if (errorData.length > 0) {
                                    that.isEndDataNext = true

                                    // errorStr = errorStr + '处理超时,请查看执行日志!'
                                    // that.$alert('设备' + errorStr, '执行结果', {
                                    //     confirmButtonText: '确定',
                                    // });
                                } else {
                                    that.$modal.msgSuccess('执行成功')

                                }

                                console.log(respons, '12311313', errorData);
                            }
                        })


                        // that.$modal.msgSuccess(res.message)
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })

            }
            console.log('停止', this.form);
        },
        backHeld() {
            let that = this
            that.sumProgress = 0
            if (this.operationtype == 0) {
                let data = {}
                data.type = 4
                data.equ_id = this.formcs.id
                that.loadings = true
                equmovecommand(data).then(res => {
                    if (res.code == 200) {
                        that.equResult(that.formcs.equ_no, res.data.message_id).then(resd => {
                            if (resd.code == 200) {
                                that.loadings = false
                                that.$modal.msgSuccess(resd.message)
                            } else {
                                that.loadings = false
                                that.$modal.msgError('设置超时，执行结果请查看执行记录!')
                            }
                        })
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })
            } else {
                let data = {}
                data.type = 4
                data.equ_id = that.idsall == '' ? that.ids : that.idsall
                that.loadings = true
                equbatchmovecommand(data).then(res => {

                    console.log(res);
                    if (res.code == 200) {
                        if (res.data.length == 0) {
                            that.loadings = false
                            that.$modal.msgError('请核实设备')
                            return
                        }
                        let arr = []
                        that.executeSequentialRequests(res.data, 0, (respons) => {
                            if (respons != 'ok') {
                                arr.push(respons)

                            } else {
                                //待测
                                that.endDataNext = arr
                                let errorData = []
                                let errorStr = ''
                                arr.map(item => {
                                    if (item.status == 0) {
                                        errorData.push(item)
                                        errorStr += item.equ_no + ','
                                    }
                                })
                                that.loadings = false
                                if (errorData.length > 0) {
                                    that.isEndDataNext = true

                                    // errorStr = errorStr + '处理超时,请查看执行日志!'
                                    // that.$alert('设备' + errorStr, '执行结果', {
                                    //     confirmButtonText: '确定',
                                    // });
                                } else {
                                    that.$modal.msgSuccess('执行成功')

                                }

                                console.log(respons, '12311313', errorData);
                            }
                        })


                        // that.$modal.msgSuccess(res.message)
                    } else {
                        that.loadings = false
                        that.$modal.msgError(res.message)
                    }
                })

            }
            console.log('返回', this.formcs);
        },
        parameterHeld() {
            let that = this
            that.sumProgress = 0
            if (that.operationtype == 0) {
                that.getList()
            } else {
                that.innerVisible = true
            }

            console.log('参数设置', this.formcs);
        },
        videoHeld() {
            this.videoInnerVisible = true
            console.log('视频监控', this.formcs);
        },
        journalHeld() {
            console.log('日志', this.formcs);
        },
        timingHeld() {
            console.log('定时任务', this.formcs);
            this.getFxList()

        },
        setoldHeld() {
            this.getoldList()
            console.log('执行历史', this.formcs);


        },
        historyHeld() {
            console.log('历史设置');
            this.gettrList()
        },
        cancel(a) {
            console.log('222', a);
            if (a) {
                this.$emit('OperationHeld', a);
            } else {
                this.$emit('OperationHeld', false);
            }
        },
        canceltr() {
            this.timingVisible = false
        },
        timingVisibleHeld() {
            let that = this
            let params = {}
            that.sumProgress = 0
            if (that.operationtype == 0) {
                let data = {}
                params.equ_id = that.formcs.id
                if (that.formdw.name == 'D') {
                    if (that.formdw.value == '') {
                        return that.$modal.msgError('间隔不能为空')
                    }
                    data.T001 = 'D' + that.formdw.value
                } else {
                    if (that.checkboxGroup1.length == 0) {
                        return that.$modal.msgError('请选择星期')
                    }
                    let str = ''
                    that.checkboxGroup1.map(item => {
                        str += item
                    })
                    data.T001 = str
                }
                data.T002 = ''
                that.timepickerlist.map(item => {
                    data.T002 += parseTime(item.value, '{h}{i}') + item.state + ','
                })
                data.T002 = data.T002.slice(0, -1)
                if (data.T002.indexOf('nullE') != -1) {
                    return that.$modal.msgError('请完善时间点')
                }

                data.T003 = parseTime(that.formdw.T003, '{y}{m}{d}{h}{i}{s}')
                if (data.T003 == null) {
                    return that.$modal.msgError('请选择生效日期')
                }
                params.data = JSON.stringify(data)
                console.log(params);
                that.loadingtr = true
                equsettimer(params).then(res => {
                    if (res.code == 200) {
                        that.equSetTimerResult(that.formcs.equ_no, res.data.message_id).then(resd => {
                            if (resd.code == 200) {
                                that.loadingtr = false
                                that.$modal.msgSuccess(resd.message)
                                this.timingVisible = false
                            } else {
                                that.loadingtr = false
                                that.$modal.msgError('设置超时，执行结果请查看执行记录!')
                            }
                        })
                    } else {
                        that.loadingtr = false
                        that.$modal.msgError(res.message)
                    }
                })
            } else {
                params.equ_id = that.idsall == '' ? that.ids : that.idsall
                let data = {}
                if (that.formdw.name == 'D') {
                    if (that.formdw.value == '') {
                        return that.$modal.msgError('间隔不能为空')
                    }
                    data.T001 = 'D' + that.formdw.value
                } else {
                    if (that.checkboxGroup1.length == 0) {
                        return that.$modal.msgError('请选择星期')
                    }
                    let str = ''
                    that.checkboxGroup1.map(item => {
                        str += item
                    })
                    data.T001 = str
                }
                data.T002 = ''
                that.timepickerlist.map(item => {
                    data.T002 += parseTime(item.value, '{h}{i}') + item.state + ','
                })
                data.T002 = data.T002.slice(0, -1)
                if (data.T002.indexOf('nullE') != -1) {
                    return that.$modal.msgError('请完善时间点')
                }
                data.T003 = parseTime(that.formdw.T003, '{y}{m}{d}{h}{i}{s}')
                if (data.T003 == null) {
                    return that.$modal.msgError('请选择生效日期')
                }
                params.data = JSON.stringify(data)
                console.log(params);
                that.loadingtr = true
                equbatchtimerresult(params).then(res => {
                    if (res.code == 200) {
                        if (res.data.length == 0) {
                            that.loadingtr = false
                            that.$modal.msgError('请核实设备')
                            return
                        }
                        let arr = []
                        that.executeSequentialRequeststr(res.data, 0, (respons) => {
                            if (respons != 'ok') {
                                arr.push(respons)

                            } else {
                                //待测
                                that.endDataNext = arr
                                let errorData = []
                                let errorStr = ''
                                arr.map(item => {
                                    if (item.status == 0) {
                                        errorData.push(item)
                                        errorStr += item.equ_no + ','
                                    }
                                })
                                that.loadingtr = false
                                if (errorData.length > 0) {
                                    that.isEndDataNext = true

                                    // errorStr = errorStr + '处理超时,请查看执行日志!'
                                    // that.$alert('设备' + errorStr, '执行结果', {
                                    //     confirmButtonText: '确定',
                                    // });
                                } else {
                                    that.$modal.msgSuccess('执行成功')
                                    this.timingVisible = false
                                }

                                console.log(respons, '12311313', errorData);
                            }
                        })

                    } else {
                        that.loadingtr = false
                        that.$modal.msgError(res.message)
                    }
                })
            }


        },
        innerVisibleHeld() {
            let that = this
            let params = {}
            that.sumProgress = 0
            if (that.operationtype == 0) {
                params.equ_id = that.formcs.id
                let obj = {}
                obj.S001 = that.S001
                obj.S002 = that.S002
                obj.S003 = that.S003
                obj.S004 = that.S004
                obj.S005 = that.S005
                if (that.role == 1) {
                    obj.S007 = that.S007
                    obj.S008 = that.S008
                    obj.S009 = that.S009
                    obj.S010 = that.S010
                    obj.S011 = that.S011
                    obj.S012 = that.S012
                    obj.S013 = that.S013
                    obj.S014 = that.S014
                    obj.S015 = that.S015
                    obj.S016 = that.S016
                }
                params.data = JSON.stringify(obj)
                that.loadingsd = true
                equsetconfig(params).then(res => {
                    if (res.code == 200) {
                        that.equSetResult(that.formcs.equ_no, res.data.message_id).then(resd => {
                            if (resd.code == 200) {
                                that.loadingsd = false
                                that.$modal.msgSuccess(resd.message)
                                this.innerVisible = false
                            } else {
                                that.loadingsd = false
                                that.$modal.msgError('设置超时，执行结果请查看执行记录!')
                            }
                        })
                    } else {
                        that.loadingsd = false
                        that.$modal.msgError(res.message)
                    }
                })
            } else {
                params.equ_id = that.idsall == '' ? that.ids : that.idsall
                let obj = {}
                obj.S001 = that.S001
                obj.S002 = that.S002
                obj.S003 = that.S003
                obj.S004 = that.S004
                obj.S005 = that.S005
                if (that.role == 1) {
                    obj.S007 = that.S007
                    obj.S008 = that.S008
                    obj.S009 = that.S009
                    obj.S010 = that.S010
                    obj.S011 = that.S011
                    obj.S012 = that.S012
                    obj.S013 = that.S013
                    obj.S014 = that.S014
                    obj.S015 = that.S015
                    obj.S016 = that.S016
                }
                params.data = JSON.stringify(obj)
                that.loadingsd = true

                equbatchsetconfig(params).then(res => {
                    if (res.code == 200) {
                        if (res.data.length == 0) {
                            that.loadingsd = false
                            that.$modal.msgError('请核实设备')
                            return
                        }
                        let arr = []
                        that.executeSequentialRequestst(res.data, 0, (respons) => {
                            if (respons != 'ok') {
                                arr.push(respons)

                            } else {
                                //待测
                                that.endDataNext = arr
                                let errorData = []
                                let errorStr = ''
                                arr.map(item => {
                                    if (item.status == 0) {
                                        errorData.push(item)
                                        errorStr += item.equ_no + ','
                                    }
                                })
                                that.loadingsd = false
                                if (errorData.length > 0) {
                                    that.isEndDataNext = true

                                    // errorStr = errorStr + '处理超时,请查看执行日志!'
                                    // that.$alert('设备' + errorStr, '执行结果', {
                                    //     confirmButtonText: '确定',
                                    // });
                                } else {
                                    that.$modal.msgSuccess('执行成功')
                                    that.innerVisible = false
                                }

                                console.log(respons, '12311313', errorData);
                            }
                        })


                    } else {
                        that.loadingsd = false
                        that.$modal.msgError(res.message)
                    }
                })
            }

            console.log('参数设置', params);
        }
    },

};
</script>

<style lang="scss" scoped>
// @keyframes fadeIn {
//     from {
//         opacity: 0;
//         transform: translateY(-100%);
//     }

//     to {
//         opacity: 1;
//         transform: translateY(0px);
//     }
// }

// ::v-deep .customclassdialog {
//     border-radius: 10px !important;
//     animation: fadeIn 1s ease-in-out forwards;
// }

.seilddiys {
    padding: 5px 0;
}

.seilddiys_title {
    color: #606266;
    // font-weight: bold;
    line-height: normal;
    font-size: 16px;
    margin-bottom: 4px;
}

::v-deep .el-checkbox {
    margin-right: 0 !important;
}
</style>